// stores>student.js
import { ref, computed } from 'vue';
import { defineStore } from "pinia";

// 创建一个useStudentStore的方法
export const useStudentStore = defineStore('student', () => {
    //state
    let name = ref('张三');
    let age = ref(22);
    let gender = ref(1);
    // getter
    const genderStr = computed(() => {
        return gender.value == 1 ? '男' : '女';
    });
    //actions
    const changeName = (newName) => {
        name.value = newName;
    }
    // 一定要记得返回
    return { name, age, gender, genderStr, changeName }
})